package prepared;

import java.sql.*;
import java.util.Scanner;

public class demo4 {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入用户的账号:");
        String name=sc.next();
        System.out.println("请输入用户的密码:");
        String pwd=sc.next();
        String sql="select * from t_yzy where name='"+name+"'and pwd='"+pwd+"'";
        login(sql);
    }
    public static void login(String sql) throws Exception {
        Connection con=jdbc.getCo();
        Statement stm=con.createStatement();
        ResultSet rs= stm.executeQuery(sql);
        if (rs.next()) {
            System.out.println("登录成功");
        } else {
            System.out.println("登录失败");
            con.close();
        }

    }

    }
